package com.huwei.boxuegu.activity;

import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.graphics.Color;
import android.media.Image;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.huwei.boxuegu.R;
import com.huwei.boxuegu.fragment.CourseFragment;
import com.huwei.boxuegu.fragment.ExerciseFragment;
import com.huwei.boxuegu.fragment.MyFragment;

public class MainActivity extends AppCompatActivity {
    FragmentManager fragmentManager;
    FragmentTransaction fragmentTransaction;
    ImageView courseImg;
    ImageView exerciseImg;
    ImageView myImg;
    TextView couseTv;
    TextView exerciseTv;
    TextView myTv;


    /*
        */

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);
        courseImg = (ImageView) findViewById(R.id.course_img);
        exerciseImg = (ImageView) findViewById(R.id.exercise_img);
        myImg = (ImageView) findViewById(R.id.my_img);
        couseTv = (TextView) findViewById(R.id.course_tv);
        exerciseTv = (TextView) findViewById(R.id.exercise_tv);
        myTv = (TextView) findViewById(R.id.my_tv);

         fragmentManager = getFragmentManager();
       fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.add(R.id.fragment,new CourseFragment());
        fragmentTransaction.commit();

        courseImg.setImageResource(R.drawable.main_course_icon_selected);
        exerciseImg.setImageResource(R.drawable.main_exercises_icon);
        myImg.setImageResource(R.drawable.main_my_icon);
        couseTv.setTextColor(Color.parseColor("#ACCCF4"));
        exerciseTv.setTextColor(Color.parseColor("#9C9C9C"));
        myTv.setTextColor(Color.parseColor("#9C9C9C"));

    }

    public void course(View view){
        courseImg.setImageResource(R.drawable.main_course_icon_selected);
        exerciseImg.setImageResource(R.drawable.main_exercises_icon);
        myImg.setImageResource(R.drawable.main_my_icon);
        couseTv.setTextColor(Color.parseColor("#ACCCF4"));
        exerciseTv.setTextColor(Color.parseColor("#9C9C9C"));
        myTv.setTextColor(Color.parseColor("#9C9C9C"));

        fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.replace(R.id.fragment,new CourseFragment());
        fragmentTransaction.commit();
    }
    public void exercise(View view){
        courseImg.setImageResource(R.drawable.main_course_icon);
        exerciseImg.setImageResource(R.drawable.main_exercises_icon_selected);
        myImg.setImageResource(R.drawable.main_my_icon);
        couseTv.setTextColor(Color.parseColor("#9C9C9C"));
        exerciseTv.setTextColor(Color.parseColor("#ACCCF4"));
        myTv.setTextColor(Color.parseColor("#9C9C9C"));


        fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.replace(R.id.fragment,new ExerciseFragment());
        fragmentTransaction.commit();

    }
    public void my(View view){
        courseImg.setImageResource(R.drawable.main_course_icon);
        exerciseImg.setImageResource(R.drawable.main_exercises_icon);
        myImg.setImageResource(R.drawable.main_my_icon_selected);
        couseTv.setTextColor(Color.parseColor("#9C9C9C"));
        exerciseTv.setTextColor(Color.parseColor("#9C9C9C"));
        myTv.setTextColor(Color.parseColor("#ACCCF4"));

        fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.replace(R.id.fragment,new MyFragment());
        fragmentTransaction.commit();
    }
}
